/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package dao.question;

import dao.DaoAbstract;
import entities.question.AbstractQuestion;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

/**
 *
 * @author aurelien.emery
 */
@Stateless
public class DaoAbstractQuestion extends DaoAbstract<AbstractQuestion> implements DaoAbstractQuestionLocal {
    @PersistenceContext(unitName = "EJBProjetEFPPU")
    private EntityManager em;

    protected EntityManager getEntityManager() {
        return em;
    }

    public DaoAbstractQuestion() {
        super(AbstractQuestion.class);
    }

    @Override
    public List<AbstractQuestion> findAll() {
        Query q = em.createNamedQuery("AbstractQuestion.findAllQuestion");
        //q.setParameter("title", recherche + "%");
        return q.getResultList();
    }

    @Override
    public long getLastIdQuestion() {
        Query q = em.createNamedQuery("AbstractQuestion.findLastIdQuestion");
        return (Long)q.getResultList().get(0);
    }

}
